/**
 * Created by zhulingxiao on 2017/6/7.
 */
import { connect } from 'react-redux';

import Menu from '../../pages/Menu/index';

import { openModal, closeModal } from '../../redux/actions/modal';

import { menuFetch, menuDelete, menuUpdate, menuAdd } from '../../redux/actions/menu'

const mapStateToProps = (state) => {

  return {
    tableLoading:state.table.loading,
    // modalLoading:state.modal.loading,
     visible:state.modal.visible,
    //modalData:state.user.data,
    sideMenu:state.menu.data
  }
};

const mapDispatchToProps = (dispatch) => {

  return {

    onFetch: () => {
      dispatch(menuFetch())
    },

    openModal:() => {
      dispatch(openModal())
    },

    closeModal:() => {
      dispatch(closeModal())
    },

    deleteMenu:(sysid) => {
      dispatch(menuDelete(sysid))
    },

    updateMenu:(data) => {

      dispatch(menuUpdate(data));

      //dispatch(closeModal());

    },

    addMenu:(data) => {

      dispatch(menuAdd(data))

    }

  }

};

const Con_Menu = connect(
  mapStateToProps,
  mapDispatchToProps
)(Menu);

export default Con_Menu

